/*****************************************************
Copyright (C) 2020. All rights reserved.
File name     ：RedBlackTree.h
Version       ：v1.0
Author        ：zhengqijun
Date          ：2020-05-07
Function List ：
Description   ：Red Black Tree(Top-down)
******************************************************/

#ifndef REDBLACKTREE_H_
#define REDBLACKTREE_H_

// Type Definition
struct RedBlackNode;
typedef int ElementType;
typedef struct RedBlackNode *Position;
typedef struct RedBlackNode *RedBlackTree;

// Function Lists
RedBlackTree Initialize(void);
RedBlackTree MakeEmpty(RedBlackTree T);
void Destroy(RedBlackTree T);
int IsEmpty(RedBlackTree T);
Position Find(ElementType Item, RedBlackTree T);
Position FindMin(RedBlackTree T);
Position FindMax(RedBlackTree T);
RedBlackTree Insert(ElementType Item, RedBlackTree T);
RedBlackTree Remove(ElementType Item, RedBlackTree T);
Position Left(Position P);
Position Right(Position P);
ElementType Retrieve(Position P);
void PreorderTraversal(RedBlackTree T);
void InorderTraversal(RedBlackTree T);
void PostorderTraversal(RedBlackTree T);
void LevelorderTraversal(RedBlackTree T);

// PrintTree for testing
void PrintTree(RedBlackTree T, int depth);

#endif  /* REDBLACKTREE_H_ */

// EOF

